package example

import grails.gorm.multitenancy.CurrentTenant
import grails.gorm.multitenancy.Tenants
import org.grails.datastore.mapping.mongo.MongoDatastore
import org.grails.datastore.mapping.multitenancy.web.SessionTenantResolver

class PersonController {

    @CurrentTenant(datastore = MongoDatastore)
    def index() {
        new Person(name: "aaa", gender: 0).save(flush: true)
        render "${Tenants.currentId(MongoDatastore)}>>$Person.count"
    }

    def select() {
        session.setAttribute(SessionTenantResolver.ATTRIBUTE, "tenant1")
        render Tenants.currentId(MongoDatastore)
    }
}
